package com.lglbc.day15;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;

/**
 * @Author 乐哥聊编程
 * @Doc 关注公众号"乐哥聊编程"获取文档和源码
 * @Date 2023/4/18
 * @Description
 */
@Service
public class SecurityExpressService {
    @PreAuthorize("@permission.check(#value)")
    public String customPermission(String value){
        return value;
    }
    @PreAuthorize("hasAuthority('ROLE_admin')")
    public String hasAuthority(String value){
        return value;
    }
    @PreAuthorize("hasAnyAuthority('ROLE_admin','ROLE_user')")
    public String hasAnyAuthority(String value){
        return value;
    }
    @PreAuthorize("hasRole('admin')")
    public String hasRole(String value){
        return value;
    }
    @PreAuthorize("hasAnyRole('admin','user')")
    public String hasAnyRole(String value){
        return value;
    }
    @PreAuthorize("principal.username=='lglbc'")
    public String principal(String value){
        return value;
    }
    @PreAuthorize("permitAll()")
    public String permitAll(String value){
        return value;
    }
    @PreAuthorize("denyAll()")
    public String denyAll(String value){
        return value;
    }
}
